import utils from "@/utils"
import type { Component } from "vue"
import type { RouteRecordRaw } from "vue-router"

// All TSX files under the views folder automatically generate mapping relationship
const module = import.meta.glob('/src/views/**/**.tsx')
const components:{[key:string]: Component} = utils.mapping(module)

const basePage: RouteRecordRaw[] =[
    {
        path: '/',
        redirect: {name: 'home'},
        meta: {title: '首页'},
        component: ()=>import('@/layouts'),
        children: [
            {
                path: '/home',
                name: 'home',
                component: components['home'],
                meta: {title: '首页', activeMenu: 'home', auth:[]}
            }
        ]
    }
]

const loginPage: RouteRecordRaw[] = [
    {
        path:'/login',
        name: 'login',
        component: components['login'],
        meta: {
            auth: []
        }
    }
]

const route: RouteRecordRaw[] = [
    ...basePage, ...loginPage
]
export default route
